<?php
include 'dbconfig.php'; 
mysql_select_db($db, $con);

$cid = mysql_real_escape_string($_POST['cid']);

$hash = md5($cid.mt_rand());

$query2 = "INSERT INTO course_instances VALUES (0, '$hash', '$cid', 2009, 0, '8.5000', 'N.N.')";

mysql_query($query2);

echo mysql_insert_id();

mysql_close($con);

?>